from proxy.proxy_service import ProxyService
from model.proxy import Proxy, ProxyType
from model.error import ParkSpiderError, ParkSpiderErrorCode

target_url = "http://httpbin.org/ip"
proxy_host = "http-dynamic.xiaoxiangdaili.com"
proxy_port = 10030
proxy_username = "952939558214193152"
proxy_pwd = "oVgRJL25"


class TunnelProxyService_XX(ProxyService):
    def take(self, platformId: int) -> Proxy:
        try:
            meta = f"http://{proxy_username}:{proxy_pwd}@{proxy_host}:{proxy_port}"
            return Proxy(meta, ProxyType.Tunnel)
        except Exception as e:
            raise ParkSpiderError(ParkSpiderErrorCode.ProxyFail, repr(e))
